import { createSlice } from "@reduxjs/toolkit"

const initState: MyToastState = {
    text: '123',
    show: false,
    type: 'warning'
}

const toastSlice = createSlice({
    name: 'mytoast',
    initialState: initState,
    reducers: {
        show(state, action) {
            state.text = action.payload.text as string;
            state.type = action.payload.type;
            state.show = true;
            // state = action.payload;            
        },
        hide(state) {
            state.show = false;
        }
    }
})

export const { show, hide } = toastSlice.actions;
export default toastSlice.reducer;